using System;
using Dll.Essences;
using Dll.DAL;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Price_Guide
{
    public partial class EqualPrice : Form
    {
        public int index;
        public EqualPrice(List<Providers> l, int[] TempPrice,string goodsname)
        {
            InitializeComponent();
            label1.Text = goodsname;
            for (int i = 0; i < TempPrice.Length; i++)
            {
                listView1.Items.Add(l[TempPrice[i]].Name);
            }
            listView1.Items[0].Checked = true;
            this.Icon = Price_Guide.Properties.Resources.Icon_64;
        }

        private void listView1_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            for (int i = 0; i < listView1.Items.Count; i++)
            {
                if (i != e.Index)
                    listView1.Items[i].Checked = false;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            index = listView1.CheckedItems[0].Index;
            this.DialogResult = DialogResult.OK;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        private void listView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
                button1_Click(null, null);
        }

        private void button2_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 27)
                this.Close();
        }

        private void EqualPrice_Load(object sender, EventArgs e)
        {
            this.Icon = Price_Guide.Properties.Resources.Icon_64;
        }
    }
}